<!DOCTYPE html>
<html lang="en">
<?php
include_once("u_checkLogin.php");
include_once("u_getLoginInfo.php");
?>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="shortcut icon" href="../public/pic/f.png" type="image/x-icon">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>信息·病例信息</title>
    <link rel="stylesheet" href="../public/css/bootstrap.min.css">
    <link rel="stylesheet" href="../public/css/user_public.css">
    <script src="../public/js/bootstrap.bundle.min.js"></script>
    <link rel="stylesheet" href="css/user_petCases.css">
    <script src="js/u_petCases.js"></script>
</head>

<body>
    <!-- 头部信息开始 -->
    <header>
        <nav class="nav-top">
            <!-- 网站logo -->
            <div class="logo">
                <img src="../public/pic/logo-h-w.png" alt="动物家宠物医院">
            </div>
            <!-- 登录者信息 -->
            <div class="user-info">
                <div class="user-info-con">
                    <span>现在时间：<span id="nowtime"></span></span>
                    <script src="../public/js/getnowtime.js"></script>
                    <br>
                    <span>当前登录：<name>
                            <?php echo $userName; ?>
                        </name></span>
                </div>
                <a href="u_logout.php">点我退出</a>
            </div>
        </nav>
    </header>
    <!-- 头部信息结束 -->

    <!-- 主要内容开始 -->
    <main>
        <!-- 网页导航开始-->
        <nav>
            <ul class="nav nav-tabs nav-main">
                <li class="nav-item nav-main-item">
                    <a class="nav-link active" aria-current="page" href="user_myinfo.php">个人信息</a>
                </li>
                <li class="nav-item nav-main-item">
                    <a class="nav-link" href="user_index.php">主页</a>
                </li>
                <li class="nav-item nav-main-item">
                    <a class="nav-link" href="user_nowOrder.php">预约服务</a>
                </li>
            </ul>
        </nav>
        <!-- 网页导航结束 -->
        <!-- 侧边导航栏开始 -->
        <div class="aside-navbar">
            <p>菜 单 栏</p>
            <ul>
                <a href="user_myinfo.php">
                    <li>个人信息</li>
                </a>
                <a href="user_petCases.php">
                    <li class="li-c">宠物病例</li>
                </a>
                <a href="user_myPetinfo.php">
                    <li>我的宠物</li>
                </a>
                <a href="user_addPetinfo.php">
                    <li>添加宠物信息</li>
                </a>
                <a href="user_myMsg.php">
                    <li>我的留言</li>
                </a>
                <a href="user_changeMyInfo.php">
                    <li>修改个人信息</li>
                </a>
                <a href="user_changePassword.php">
                    <li>修改登录密码</li>
                </a>
                <a href="user_delAccount.php">
                    <li>注销账号信息</li>
                </a>
            </ul>
        </div>
        <!-- 侧边导航栏结束 -->
        <!-- 主要内容开始 -->
        <div class="main-content">
            <p class="main-content-title">病 例 信 息</p>
            <div class="cases-info-div">
                <div class="cases-info-div-left">
                    <?php
                    include_once("conn.php");
                    $select_cases = "SELECT * FROM cases_infos WHERE cases_userID = '" . $userID . "' ORDER BY cases_date DESC";
                    $result_cases = mysqli_query($connect_DB, $select_cases);
                    if ($result_cases) {
                        echo "
                            <h5>病 例 列 表 </h5>
                            <div class='cases-list-div'>";
                        if (mysqli_num_rows($result_cases) < 0) {
                            echo "<div class='list-cases'>暂无病例信息</div>";
                        } else {
                            $count = 1;
                            while ($row_cases = mysqli_fetch_object($result_cases)) {
                                $select_pet = "SELECT * FROM pet_infos WHERE pet_ID = '" . $row_cases->cases_petID . "' AND user_ID = '" . $userID . "'";
                                $result_pet = mysqli_query($connect_DB, $select_pet);
                                if(mysqli_num_rows($result_pet) <= 0){
                                    continue;
                                }
                                $select_order = "SELECT * FROM order_history_infos WHERE order_ID = '" . $row_cases->cases_ID . "'";
                                $result_order = mysqli_query($connect_DB, $select_order);
                                if($result_order){
                                    $row_order = mysqli_fetch_object($result_order);
                                    echo "
                                        <div class='list-cases' id='" . $count . "'>
                                            <div class='casesID'>" . $row_cases->cases_ID . "</div>
                                            <div class='petName'>" . $row_cases->cases_petName . "</div>
                                            <div class='orderType'>" . $row_cases->cases_orderType . "</div>
                                            <div class='orderDate'>" . $row_order->order_Date . "</div>
                                        </div>
                                        ";
                                }
                                $count++;
                            }
                        }
                        echo "</div>";
                    } else {
                        echo "查询失败" . $select_cases;
                    }
                    ?>
                </div>
                <div class="cases-info-div-right">
                    <h5>病 例 详 情</h5>
                    <div class="cases-content" id="cases-content"> </div>
                </div>

            </div>
        </div>
        <!-- 主要内容结束 -->
    </main>
    <!-- 主要内容结束 -->
    <!-- 底部开始 -->
    <footer>
        <p>&copy; 2025 ANIMAL HOME PET HOSPITAL. All rights reserved.</p>
    </footer>
    <!-- 底部结束 -->
</body>

</html>